package dongze.com.ckdj.persistence;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.github.yuweiguocn.library.greendao.MigrationHelper;

import org.greenrobot.greendao.database.Database;

import dongze.com.ckdj.persistence.dao.DaoMaster;
import dongze.com.ckdj.persistence.dao.Image;
import dongze.com.ckdj.persistence.dao.ImageDao;
import dongze.com.ckdj.persistence.dao.MartinImageCheckInRecord;
import dongze.com.ckdj.persistence.dao.MartinImageCheckInRecordDao;
import dongze.com.ckdj.persistence.dao.MassLossUploadRecordDao;
import dongze.com.ckdj.persistence.dao.NamePlateUploadRecordDao;
import dongze.com.ckdj.persistence.dao.ServerUploadTaskDao;

/**
 * Created by fanqwz on 2017/7/31.
 */

public class SQLiteHelper extends DaoMaster.OpenHelper {
    public SQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
        super(context, name, factory);
    }
    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {

            @Override
            public void onCreateAllTables(Database db, boolean ifNotExists) {
                DaoMaster.createAllTables(db, ifNotExists);
            }

            @Override
            public void onDropAllTables(Database db, boolean ifExists) {
                DaoMaster.dropAllTables(db, ifExists);
            }
        },
                ImageDao.class,
                MartinImageCheckInRecordDao.class,
                MassLossUploadRecordDao.class,
                NamePlateUploadRecordDao.class,
                ServerUploadTaskDao.class);
    }
}